package cn.antsing;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * 被访问者
 */
public class Customer implements IVisitable {
    private String name;
    private List<Order> orders = new ArrayList<Order>();
    public void accept(IVisitor visitor) {
        visitor.visit(this);
        for(Iterator<Order> orderIterator = orders.iterator();orderIterator.hasNext();){
            orderIterator.next().accept(visitor);
        }
    }

    public Customer(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    public void addOrder(Order order){
        orders.add(order);
    }
}
